<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>


<!DOCTYPE html>
<s:layout-render name="../../layout.jsp" title="moduleNames.rooms" selectedPage="hotels">
    <s:layout-component name="left-column">
        <h3><f:message key="global.menu" /></h3>
        <ul class="nav">
            <li><s:link beanclass="cz.muni.fi.pa165.bookingmanager.web.HotelActionBean" event="all"><f:message key="global.back_to_list" /> <f:message key="moduleNames.fourth_variant.hotels" /></s:link></li>        
        </ul>
    </s:layout-component>
        
    <s:layout-component name="body">
    <s:useActionBean beanclass="cz.muni.fi.pa165.bookingmanager.web.RoomActionBean" var="actionBean"/>    
        <s:form beanclass="cz.muni.fi.pa165.bookingmanager.web.RoomActionBean">
            <jsp:setProperty name="actionBean" property="*"/>
            <div class="select-bar">
                <s:text size="40" name="roomNumber"/>
                <s:submit name="findRoomByNumber">
                    <f:message key="global.search_room_by_number" /></s:submit>
            </div>
        </s:form>
    
        <div class="table">
            <table class="listing" cellpadding="0" cellspacing="0">
                <img src="${pageContext.request.contextPath}/backend/img/bg-th-left.gif" width="8" height="7" alt="" class="left" /> 
                <img src="${pageContext.request.contextPath}/backend/img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
                <tr>
                    <th class="first"><f:message key="global.hotel.rooms" /> ${actionBean.context.hotel.name}</th>
                </tr>
                <tr>
                    <th class="first"><f:message key="entities.room.room_Number" /></th>
                    <th><f:message key="entities.room.capacity" /></th>
                    <th><f:message key="entities.room.price" /></th>                    
                    <shiro:hasRole name="admin"><th><f:message key="global.edit" /></th></shiro:hasRole>
                    <shiro:hasRole name="admin"><th class="last"><f:message key="global.delete" /></th></shiro:hasRole>
                </tr>           
            <c:forEach var="room" items="${actionBean.getList()}">
                <tr>                
                    <td class="first_style1" ><c:out value="${room.roomNumber}"/></td>
                    <td><c:out value="${room.capacity}"/></td>
                    <td><c:out value="${room.price}"/> €</td>                   
                    <shiro:hasRole name="admin"><td><s:link beanclass="cz.muni.fi.pa165.bookingmanager.web.RoomActionBean" event="edit"><s:param name="room.id" value="${room.id}" /><img src="${pageContext.request.contextPath}/backend/img/edit-icon.gif" /></s:link></td></shiro:hasRole>
                    <shiro:hasRole name="admin"><td class="last"><s:link onclick="return confirm_delete()" beanclass="cz.muni.fi.pa165.bookingmanager.web.RoomActionBean" event="delete"><s:param name="room.id" value="${room.id}" /><img src="${pageContext.request.contextPath}/backend/img/hr.gif" /></s:link></td></shiro:hasRole>
                </tr>
            </c:forEach>
           </table>
        </div>
         
         <shiro:hasRole name="admin">
         <s:form beanclass="cz.muni.fi.pa165.bookingmanager.web.RoomActionBean" >               
                <c:import url="form.jsp">
                   <c:param name="header" value="global.add" />
                </c:import>                
                <s:submit class="button" name="add">
                    
                <f:message key="global.add" /></s:submit>
          </s:form> 
         </shiro:hasRole>
           
    </s:layout-component>
</s:layout-render>
